from django.contrib import admin
from .models import CityModel,ProvinceModel,AreaModel
# Register your models here.

class CityTableInline(admin.TabularInline):
    model = CityModel
    fields = ('id', 'name')

class AreaTableInline(admin.TabularInline):
    model = AreaModel
    fields = ('id', 'name')


class ProvinceAdmin(admin.ModelAdmin):
    ordering = ('id',)
    list_display = ('id', 'name')
    inlines = [CityTableInline]



class CityAdmin(admin.ModelAdmin):
    ordering = ('id',)
    list_display = ('id', 'name','province')
    inlines = [AreaTableInline]


class AreaAdmin(admin.ModelAdmin):
    ordering = ('id',)
    list_display = ('id', 'name','city')


admin.site.register(ProvinceModel,ProvinceAdmin)
admin.site.register(CityModel,CityAdmin)
admin.site.register(AreaModel,AreaAdmin)


